<?php
/**
 * Pertyler DatabaseManagement
 * DatabaseModel
 * Main Classes
 *
 * @author	Emre Hasegeli <hasegeli@gmail.com>
 * @license	GNU General Public License v3
 */

namespace Pertyler;

require_once __DIR__ . '/aDatabase.php';

class Database extends aDatabase
{
	public function Update($query)
	{
		try
		{
			$this->postgre()->SelectResultResource($query);
		}
		catch(\Pert\Postgre_exception $exception)
		{
			throw new Database_exception($exception);
		}

		return true;
	}

	public function UpdateTransactionBegin()
	{
		$this->Update('BEGIN');

		return true;
	}

	public function UpdateTransactionCommit()
	{
		$this->Update('COMMIT');

		return true;
	}

	public function UpdateTransactionRollback()
	{
		$this->Update('ROLLBACK');

		return true;
	}

	public function SelectResultArrayArray($query)
	{
		try
		{
			return $this->postgre()->SelectResultArrayArray($query);
		}
		catch(\Pert\Postgre_exception $exception)
		{
			throw new Database_exception($exception);
		}
	}

	public function SelectResultArray($query)
	{
		try
		{
			return $this->postgre()->SelectResultArray($query);
		}
		catch(\Pert\Postgre_exception $exception)
		{
			throw new Database_exception($exception);
		}
	}

	public function SelectResult($query)
	{
		try
		{
			return $this->postgre()->SelectResult($query);
		}
		catch(\Pert\Postgre_exception $exception)
		{
			throw new Database_exception($exception);
		}
	}

	public function SelectInput($id)
	{
		return $this->postgre()->SelectInput($id);
	}
}

class Database_exception extends \Exception
{
}
